import org.junit.Test;

import java.io.File;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;

public class LocalDateTimeTest {
    @Test
    public void test01() {
        LocalDate now = LocalDate.now();
        System.out.println(now);
    }

    @Test
    public void test02() {
        LocalTime now = LocalTime.now();
        System.out.println(now);
    }

    @Test
    public void test03() {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
    }

    @Test
    public void test04() {
        LocalDate now = LocalDate.of(2024, 11, 8);
        System.out.println(now);
    }

    @Test
    public void test011() {
        LocalDate lai = LocalDate.of(2024, 11, 8);
        System.out.println(lai.getDayOfYear());
    }

    @Test
    public void test06() {
        LocalDate lai = LocalDate.of(2024, 11, 8);
        LocalDate go = lai.plusDays(160);
        System.out.println(go);
    }

    @Test
    public void test7() {
        LocalDate now = LocalDate.now();
        LocalDate before = now.minusDays(100);
        System.out.println(before);
    }

    @Test
    public void test08() {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1122, "1");
        map.put(2233, "2");

//        for (var entry : map.entrySet()) {
//            System.out.println(entry.getClass().getName());
//            System.out.println(entry.getKey() + ":" + entry.getValue());
//        }

        var values = map.values();
        System.out.println(values.getClass().getName());
    }

    @Test
    public void test09() {
        File file = new File("");
        System.out.println(file.getAbsolutePath());

        Properties properties = new Properties();
    }

    @Test
    public void test10() {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }

        Collections.shuffle(list);
        for (int i : list) {
            System.out.print(i + " ");
        }
        System.out.println();

//        list.sort(Comparator.comparingInt((Integer::intValue)).reversed());
        list.sort(Collections.reverseOrder());
//        for (int i : list) {
//            System.out.print(i + " ");
//        }

        System.out.println(list.stream().max(Integer::compareTo).get());
//        Collections.binarySearch(list, 0);

//        System.out.println();
//        Collections.swap(list, 0, 1);
//        for (int i : list) {
//            System.out.print(i + " ");
//        }

        Set<String> set = new HashSet<>(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9"));
        System.out.println(set);
    }

    @Test
    public void test11() {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
//        HashSet<Integer> set = new HashSet<>(Arrays.asList(array));

        Set<Integer> set = Arrays.stream(array).boxed().collect(Collectors.toSet());
        System.out.println(set.getClass().getName());


//        String[] array = {"apple", "banana", "orange"};
//        HashSet<String> set = new HashSet<>(Arrays.asList(array));
    }
}

class ArrayToHashSetExample {
    public static void main(String[] args) {
        String[] array = {"apple", "banana", "orange"};

        // 将数组转为List后，再传入HashSet构造器
        Set<String> set = new HashSet<>(Arrays.asList(array));

        System.out.println(set); // 输出: [banana, orange, apple]
    }
}